import 'dart:ui';

import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/constant/constant.dart';
import 'package:distribution_mall_flutter/generated/l10n.dart';
import 'package:distribution_mall_flutter/utils/image_loader.dart';
import 'package:distribution_mall_flutter/router/router.dart';
import 'package:distribution_mall_flutter/router/router.gr.dart';
import 'package:distribution_mall_flutter/widgets/ink_well_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ContentOrder extends StatefulWidget {
  const ContentOrder({super.key});

  @override
  State<ContentOrder> createState() {
    return ContentOrderState();
  }
}

class ContentOrderState extends State<ContentOrder> {
  final orderTextStyles =
      const TextStyle(color: Color.fromRGBO(102, 102, 102, 1), fontSize: 10);
  final List<Map<dynamic, dynamic>> ordersText = [
    {
      'img': 'peding.png',
      'text': S.current.order_pending,
    },
    {
      'img': 'delivered.png',
      'text': S.current.order_delivered,
    },
    {
      'img': 'received.png',
      'text': S.current.order_received,
    },
    {
      'img': 'completed.png',
      'text': S.current.order_completed,
    }
  ];

  renderOrder({required Map<dynamic, dynamic> item}) {
    return EPInkWellView(
      borderRadius: BorderRadius.circular(RadiusConstant.edge2p5),
      onPressed: () => {},
      child: Padding(
        padding: const EdgeInsets.all(EdgeConstant.edge5),
        child: Column(
          children: [
            ImageLoader.imageAsset(item['img']),
            Padding(
              padding: const EdgeInsets.only(top: 9),
              child: Text(
                // item['text'],
                '12312312',
                style: orderTextStyles,
              ),
            )
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: EdgeConstant.edge20),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                S.of(context).my_myOrder,
                style: const TextStyle(
                    color: Colors.black, fontSize: FontConstant.f15),
              ),
              TextButton(
                  onPressed: () => {appRouter.push(const OrderListRoute())},
                  style: TextButton.styleFrom(
                    padding: const EdgeInsets.only(right: 0), // 只设置左边距为10
                  ),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text(
                        S.of(context).my_viewOrder,
                        style: const TextStyle(
                            color: ColorConstant.grey153,
                            fontSize: FontConstant.f12),
                      ),
                      const Icon(
                        CupertinoIcons.right_chevron,
                        color: ColorConstant.grey153,
                        size: 12,
                      )
                    ],
                  ))
            ],
          ),
          SingleChildScrollView(
            padding: const EdgeInsets.symmetric(vertical: EdgeConstant.edge10),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: ordersText
                  .map((item) => renderOrder(item: item) as Widget)
                  .toList(),
            ),
          )
        ],
      ),
    );
  }
}
